<template>
  <view class="content">
    <view class="title">{{title}}...</view>
    <view class="art-content">
      <rich-text class="richText" :nodes="strings"></rich-text>
    </view>
  </view>
</template>

<script>
import { get } from "../../util/request.js";
export default {
  data() {
    return {
      title: "",
      strings: [],
      newsid: ""
    };
  },
  onLoad(option) {
    console.log(JSON.stringify(option));
    let newsid = option.newsid;
    this.newsid = newsid;
    // uni.request({
    //   url: "https://unidemo.dcloud.net.cn/api/news/36kr/" + newsid,
    //   method: "GET",
    //   data: {},
    //   success: res => {
    //     // console.log(JSON.stringify(res));
    //     console.log(res);
    //     this.title = res.data.title;
    //     this.strings = res.data.content;
    //   },
    //   fail: () => {},
    //   complete: () => {}
    // });
    this.getDate();
  },
  methods: {
    async getDate() {
      console.log(this.newsid);
      let data = await get(
        "https://unidemo.dcloud.net.cn/api/news/36kr/" + this.newsid
      );
      this.title = data.title;
      this.strings = data.content;
    }
  }
};
</script>

<style scoped>
.content {
  padding: 10upx 5%;
  width: 90%;
  flex-wrap: wrap;
}
.title {
  line-height: 2em;
  font-weight: 700;
  font-size: 38upx;
}
.art-content {
  line-height: 2em;
}
</style>